package com.ybxx.system.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ybxx.core.model.BaseModel;
import com.ybxx.system.SystemConstants;

/**
 * 用户表
 * 
 */
@Entity
@Table(name = "tbl_system_user")
public class User extends BaseModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7454462724198337131L;
	
	/**
	 * 登录名
	 */
	@Id
	private String loginid;

	/**
	 * 密码
	 */
	private String pwd;
	private String name;
	private String tel;
	private String state=SystemConstants.ENABLE;//0---正常，1---禁用
	
	@ManyToMany(targetEntity = Permission.class,fetch = FetchType.LAZY)
	@JoinTable(name = "tbl_system_user_permission", inverseJoinColumns = { @JoinColumn(name = "pid", referencedColumnName = "pid") }, joinColumns = { @JoinColumn(name = "loginid", referencedColumnName = "loginid") })
	private Set<Permission> permissions=new HashSet<Permission>();
	@OneToMany(targetEntity=DataRights.class,cascade={CascadeType.ALL},mappedBy="user",fetch = FetchType.LAZY)
	private Set<DataRights> dataRightsex=new HashSet<DataRights>(); 	

	public String getLoginid() {
		return loginid;
	}

	public void setLoginid(String loginid) {
		this.loginid = loginid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public Set<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}

	public Set<DataRights> getDataRightsex() {
		return dataRightsex;
	}

	public void setDataRightsex(Set<DataRights> dataRightsex) {
		this.dataRightsex = dataRightsex;
	}
	
}
